﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Box.Entities;

namespace Box.Repository.Mapping
{
    public class InsumosMap:EntityTypeConfiguration<Insumo>
    {
        public InsumosMap()
        {
            this.HasKey(p => p.Id);
            this.Property(p => p.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(p => p.NombreInsumo)
                .IsRequired()
                .HasMaxLength(150);

            this.Property(p => p.DescripcionInsumo)
                .IsOptional()
                .HasMaxLength(255);

            this.Property(p => p.MedidaInsumo)
                .IsOptional()
                .HasMaxLength(15);

            this.Property(p => p.Precio)
                .HasPrecision(9, 2)
                .IsRequired();
            this.Property(p => p.Stock)
                .HasPrecision(9, 2)
                .IsOptional();

            this.ToTable("INSUMO");

            this.Property(p => p.Id).HasColumnName("Id");
            this.Property(p => p.NombreInsumo).HasColumnName("NombreInsumo");
            this.Property(p => p.DescripcionInsumo).HasColumnName("DescripcionInsumo");
            this.Property(p => p.MedidaInsumo).HasColumnName("MedidaInsumo");
            this.Property(p => p.Precio).HasColumnName("PrecioInsumo");
            this.Property(p => p.Stock).HasColumnName("Stock");

            this.HasRequired(p => p.Marca)
    .WithMany()
    .HasForeignKey(p =>p.IdMarca)
    .WillCascadeOnDelete(false);

        }
    }
}
